import request from '@/utils/request'
import md5 from 'js-md5'

/*         通用          */
export function login (data) {
  data.password = md5(data.password)
  return request({
    url: '/admin/login',
    method: 'post',
    data
  })
}

export function getInfo (token) {
  return request({
    url: '/admin/info',
    method: 'get',
    params: { token }
  })
}

export function logout () {
  return request({
    url: '/admin/logout',
    method: 'post'
  })
}
/*         通用 end          */

/*         super·超管          */
export function getSubs () {
  return request({
    url: '/admin/getSubs',
    method: 'get'
  })
}

export function updateSub (data) {
  return request({
    url: '/admin/updateSub',
    method: 'post',
    data
  })
}

// sub super
export function getBidCos (params) {
  return request({
    url: '/admin/getBidCos',
    method: 'get',
    params
  })
}

// sub super
export function getAllBidCos (params) {
  return request({
    url: '/admin/getAllBidCos',
    method: 'get',
    params
  })
}

export function updateBidCo (data) {
  return request({
    url: '/admin/updateBidCo',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    type: 'form'
  })
}
/*         super end         */

/*         sub·代理admin          */
export function exportKeys (data) {
  return request({
    url: '/admin/exportkeys',
    method: 'post',
    data
  })
}

export function downloadKeys () {
  return request({
    url: '/admin/downloadkeys',
    method: 'get'
  })
}

export function getKeys (params) {
  return request({
    url: '/admin/getKeys',
    method: 'get',
    params
  })
}

export function password (data) {
  return request({
    url: '/admin/password',
    method: 'post',
    data
  })
}

export function getLogo () {
  return request({
    url: '/admin/getLogo',
    method: 'get'
  })
}

export function setLogo (data) {
  return request({
    url: '/admin/setLogo',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    type: 'form'
  })
}
/*         sub end         */
